Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor Trie #2355

Open
wants to merge 41 commits into
base: weiihann/improve-state-trie
Choose a base branch
from
Open

Conversation

weiihann
Copy link
Contributor

@weiihann weiihann commented Dec 31, 2024

This PR introduces a complete new Trie implementation. Some of the major changes:

  • Separation of node types - Makes code more intuitive, reduce redundant storage, separation of concerns, easier to extend functionalities
  • Performance Optimization - Stores trie in-memory, cache node hashes, Trie.Update + Trie.Commit is 4x faster
  • Range Proof - Solves the edge case of gapped range proof from the previous implementation

This PR is a standalone package and has not been integrated with the other parts of Juno. The integration and replacement of legacy trie implementation will be given in another PR.

Also, do note that the implementation of BitArray is exactly the same as before, please ignore it during the review process.

@weiihann weiihann changed the base branch from main to weiihann/improve-state-trie January 23, 2025 03:51
@weiihann weiihann marked this pull request as ready for review January 23, 2025 04:42
Copy link

codecov bot commented Jan 23, 2025

Codecov Report

Attention: Patch coverage is 72.07403% with 513 lines in your changes missing coverage. Please review.

Project coverage is 74.33%. Comparing base (4d99dd0) to head (7ef23f2).

Files with missing lines Patch % Lines
core/trie2/proof.go 67.58% 103 Missing and 38 partials ⚠️
core/trie2/trieutils/bitarray.go 73.58% 134 Missing and 6 partials ⚠️
core/trie2/trie.go 79.43% 57 Missing and 16 partials ⚠️
core/trie2/node_enc.go 60.55% 29 Missing and 14 partials ⚠️
core/trie2/node.go 44.23% 29 Missing ⚠️
core/trie2/triedb/database.go 59.70% 21 Missing and 6 partials ⚠️
core/trie2/id.go 32.35% 23 Missing ⚠️
core/trie2/trienode/nodeset.go 72.22% 10 Missing and 5 partials ⚠️
core/trie2/hasher.go 90.66% 6 Missing and 1 partial ⚠️
utils/orderedset.go 0.00% 6 Missing ⚠️
... and 3 more
Additional details and impacted files
@@                       Coverage Diff                       @@
##           weiihann/improve-state-trie    #2355      +/-   ##
===============================================================
- Coverage                        74.69%   74.33%   -0.37%     
===============================================================
  Files                              111      123      +12     
  Lines                            12581    14418    +1837     
===============================================================
+ Hits                              9398    10718    +1320     
- Misses                            2484     2914     +430     
- Partials                           699      786      +87     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant